package com.example.daibanshiwu.Service.Impl;

import com.example.daibanshiwu.Service.ArchiveService;
import com.example.daibanshiwu.mapper.ArchiveMapper;
import com.example.daibanshiwu.pojo.Archive;
import com.example.daibanshiwu.pojo.ArchiveDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArchiveServiceImpl implements ArchiveService {
    @Autowired
    private ArchiveMapper archiveMapper;

    public ArchiveServiceImpl() {}

    //查询归档
    @Override
    public List<Archive> getAllArchive(){
        System.out.println("正在查询所有归档日志信息");
        return archiveMapper.selectArchive();
    }

    //插入归档
    @Override
    public void createArchive(Archive archive){
        System.out.println("Service: 准备插入归档 ");
        archiveMapper.insertArchive(archive);
    }

    //查询
    @Override
    public  List<Archive> getPersonArchive(Long archiverUserId){
        return archiveMapper.selectPersonArchive(archiverUserId);
    }

    //查询实体类联合
    @Override
    public List<ArchiveDTO> getArchiveList() {
        return archiveMapper.findCompletedArchiveDetailsForUI();
    }
    //个人统计查询
    @Override
    public List<ArchiveDTO> getArchiveListForUser(Long userId) {
        return archiveMapper.findCompletedArchiveDetailsForUser(userId);
    }
}
